<?php

class Layout
{
	private $_layoutPath;
	private $_headerFile;
	private $_menuFile;
	private $_footerFile;
	private $_cssFiles = array();
	private $_jsFiles = array();
	private $_headerTitle = "";
	private $_bodyTitle = "";
	
	function Layout($layoutPath = null)
	{
		$this->_layoutPath = ($layoutPath == null) ? BASE_PATH . "include/layout/" : $layoutPath ;
	}
	
	public function header($headerFile = null)
	{
		global $user;
		
		$this->_headerFile = ($headerFile == null) ? "header.php" : $headerFile ;
		
		require_once($this->_layoutPath . $this->_headerFile);
	}
	
	public function menu($menuFile = null)
	{
		global $user;
		
		$this->_menuFile = ($menuFile == null) ? "menu.php" : $menuFile ;
		
		require_once($this->_layoutPath . $this->_menuFile);
	}
	
	public function usermenu($menuFile = null)
	{
		global $user;
		
		$menuFile = ($menuFile == null) ? "usermenu.php" : $menuFile ;
		
		require_once($this->_layoutPath . $menuFile);
	}
	
	public function footer($footerFile = null)
	{
		global $user, $mysql, $panel, $game;
		
		$this->_footerFile = ($footerFile == null) ? "footer.php" : $footerFile ;
		
		require_once($this->_layoutPath . $this->_footerFile);
	}
	
	public function addCss($uri)
	{
		$this->_cssFiles[] = $uri;
	}
	
	public function addJavascript($uri)
	{
		$this->_jsFiles[] = $uri;
	}
	
	public function setHeaderTitle($title)
	{
		$this->_headerTitle = $title;
	}
	
	public function setBodyTitle($title)
	{
		$this->_bodyTitle = $title;
	}
	
	private function getCss()
	{
		$baseUrl = BASE_URL;
		
		$out = "";
		foreach($this->_cssFiles AS $file)
		{
			$out .= <<<END
	<link href="{$baseUrl}static/css/{$file}.css" rel="stylesheet" type="text/css" />

END;
		}
		return $out;
	}
	
	private function getJavascript()
	{
		$baseUrl = BASE_URL;
		
		$out = "";
		foreach($this->_jsFiles AS $file)
		{
			$out .= <<<END
	<script type="text/javascript" src="{$baseUrl}static/js/{$file}.js"></script>

END;
		}
		return $out;
	}
}

?>